//
//  Car.m
//  Chapt6_CarPartsSplit
//
//  Created by RRam on 2/1/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Car.h"
#import "Tire.h"
#import "Engine.h"


@implementation Car

//M001:
- (Engine *) engine 
{
    return (engine); 
}

//M002:
- (void) setEngine: (Engine *)newEngine
{
    engine = newEngine;
}

//M003:
- (Tire *) tireAtIndex:(int)index
{
    //check index bounds...
    if (index < 0 || index > 3) 
    {
        NSLog( @"\nBad index: %d, in tireAtIndex\n", index ); 
        exit(1);
    }
    
    return ( tires[index] );
}

//M004:
- (void) setTire:(Tire *)tire atIndex:(int)index
{
    //check index bounds...
    if (index < 0 || index > 3) 
    {
        NSLog( @"\nBad index: %d, in tireAtIndex\n", index ); 
        exit(1);
    }
    
    tires[index] = tire;
}

//M005:
- (void) print
{
    NSLog( @ "%@", [engine description] );
    
    for (int i=0; i< 4; i++) 
    { 
        NSLog( @"%@", [tires[i] description] ); 
    }//for-loop
}

@end
